<include file="Public/min-header"/>
<link href="__PUBLIC__/plugins/daterangepicker/daterangepicker-bs3.css" rel="stylesheet" type="text/css" />
<script src="__PUBLIC__/plugins/daterangepicker/moment.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/plugins/daterangepicker/daterangepicker.js" type="text/javascript"></script>
<div class="wrapper">
  <include file="Public/breadcrumb"/>
  <style type="text/css">
  	.table input{display: nones;}
	#biaozhu{cursor: pointer;}
  </style> 
   
  <section class="content">
    <div class="container-fluid">
      <div class="panel panel-default">
        <div class="panel-heading"> 
          <h3 class="panel-title"><i class="fa fa-list"></i>总部/分部对账单</h3>
        </div>
        <div class="panel-body">    
		<div class="navbar navbar-default">
                <form id="search-form2" class="navbar-form form-inline"  method="get" action="{:U('pda_duizhang')}">
                <div class="form-group">
                    <!--
								<?php
								if(session('fenbu_id')==0){
								?>
								<div class="form-group">
								 <select name="fenbu_id" id="fenbu_id" class="input-sm" style="width:100px;">
									 <?php
									 foreach($fenbu_list as $v){
										if(I('fenbu_id')==$v['fenbu_id']){
											 echo '<option value="'.$v['fenbu_id'].'" selected="selected">'.$v['fenbu_name'].'</option>';
										 }else{
											 echo '<option value="'.$v['fenbu_id'].'">'.$v['fenbu_name'].'</option>';
										 }
									 }
									 ?>
								 </select>
								</div>
								<?php
								}else{
									echo '<input type="hidden" name="fenbu_id" id="fenbu_id" value="'.session('fenbu_id').'" />';
								}
								?>
								-->
                  <div class="input-group">
                    <input type="text" class="form-control" id="order_sn" placeholder="订单号" value="{$Think.request.order_sn}" name="order_sn" style="width:145px;"/>
                  </div>

                  <div class="input-group">
                    <input type="text" class="form-control" id="shanghu" placeholder="商户名" value="{$Think.request.shanghu}" name="shanghu" style="width: 100px;"/>
                  </div>
				  <div class="input-group">
				    <input type="text" class="form-control" id="kehu" placeholder="客户名" value="{$Think.request.kehu}" name="kehu" style="width: 100px;"/>
				  </div>
				<div class="form-group">
				                  <select name="jiesuan_zt" id="jiesuan_zt" class="form-control">
									<?php
									if(empty(I('jiesuan_zt'))){
										echo '<option value="0" selected="selected">未结算</option>
										<option value="1">已结算</option>';
									}else{
										echo '<option value="0">未结算</option>
										<option value="1" selected="selected">已结算</option>';
									}
									?>
				                  </select>
				</div>
                  
                   <div class="input-group margin" style="width: 350px;">
                   <div class="input-group-addon" style="width: 100px;">
                        收款时间<i class="fa fa-calendar"></i>
                    </div>
                       <input type="text" id="start_time" value="{$timegap}" autocomplete="off" name="timegap" class="form-control pull-right">
                  </div>
                </div>
                <div class="form-group">
                    <button class="btn btn-primary" id="button-filter search-order" type="submit"><i class="fa fa-search"></i> 筛选</button>
                </div>&nbsp;&nbsp;&nbsp;
				<div class="form-group">
                    <button type="button" class="btn btn-default pull-right" id="daochu"><i class="fa fa-file-excel-o"></i>&nbsp;导出excel</button>
                </div>
                </form>
			<span style="color: red;padding-left: 15px;padding-bottom: 15px;">提示：总部与分部对账时，禁止PDA跟踪收款！分部商铺单据此处不显示。
				 </span>
          </div>
                        
          <div id="ajax_return"> 
                 
                    <div class="table-responsive">
                        <table class="table table-bordered table-hover">
                            <thead>
                            <tr>
								<th class="sorting text-center">订单ID</th>
								<th class="sorting text-center">订单号</th>
                                <!-- <th class="sorting text-center">操作员</th> -->
								<th class="sorting text-center">商户名</th>
                                <th class="sorting text-center">客户名</th>
								<th class="sorting text-center">订单价</th>
								<th class="sorting text-center">扣点</th>
								<th class="sorting text-center">应收</th>
								<th class="sorting text-center">包装件数</th>
                                <th class="sorting text-center">收款时间</th>
                                <th class="sorting text-center">状态/标注</th>
                            </tr>
                            </thead>
                            <tbody>

                            <volist name="list" id="v">
                                <tr>
									<td class="text-center" id="biaozhus" rel="{$v.order_id}|{$v.store_id}">
										{$v.order_id}
										</td>
									<td class="text-center">
										<a href="javascript:" id="chakan" rel="{$v.order_id}">
										{$v.order_sn}
										</a></td> 
									<td class="text-center">{$v.store_name}</td>
                                    <td class="text-center">{$v.company}</td>
									</td>
									<td class="text-center"><span style="color:#f39c12;">{:$v['order_totals']+$v['yijia_heji']}</span></td>
									<td class="text-center"><span style="color:blue;">-{$v.commis_totals}</span></td>
									<td class="text-center"><span style="color:red;">{:$v['result_totals']+$v['yijia_heji']}</span></td>
									<td class="text-center"><b>{$v.jian_count} / 件</b>
									</td> 
									<td class="text-center"><span><?php echo date('Y-m-d H:i:s',$v[$z.'create_date']); ?></span></td>

                                    <td class="text-center">
                                        <if condition="$v[chuku_count] eq 0"><span style="color: red;">未出库</span></if>
                                        <if condition="$v[chuku_count] egt 0"><span style="color: green;">已出库</span></if>
                                    </td>
                                </tr>
                            </volist>
                            </tbody>
							<tbody>
								<tr style="font-size: 16px;color: red;">
									<td colspan="4" align="right"><b>合计：</b></td>
									<td align="center" style="color:#f39c12;">￥{$heji_dd}</td>
									<td align="center" style="color:blue;">-￥{$heji_kd}</td>
									<td align="center">￥{:$heji}</td>
									<td colspan="3"></td>
								</tr>
							</tbody>
                        </table>
                    </div>
                
                <div class="row">
                    <div class="col-sm-6 text-right">{$show}</div>
                </div>
          </div>
        </div>
      </div>
    </div>
    <!-- /.row --> 
  </section>
  <!-- /.content --> 
</div>
<!-- /.content-wrapper --> 
 <script>
	$(document).ready(function() {
		$('#start_time').daterangepicker({
			format:"YYYY-MM-DD HH:mm",
			singleDatePicker: false,
			showDropdowns: true,
			minDate:'2021-01-01 00:00',
			maxDate:'2030-01-01 00:00',
			startDate:'{:date("Y-m-d")} 00:00',
		    showWeekNumbers: true,
		    timePicker: true,
		    timePickerIncrement: 1,
		    timePicker12Hour: false,
		    ranges: {
		       '今天': [moment(), moment()],
		       '昨天': [moment().subtract('days', 1), moment().subtract('days', 1)],
		       '最近7天': [moment().subtract('days', 6), moment()],
		       '最近30天': [moment().subtract('days', 29), moment()],
		       '上一个月': [moment().subtract('month', 1).startOf('month'), moment().subtract('month', 1).endOf('month')]
		    },
		    opens: 'left',
		    buttonClasses: ['btn btn-default'],
		    applyClass: 'btn-small btn-primary',
		    cancelClass: 'btn-small',
		    locale : {
		        applyLabel : '确定',
		        cancelLabel : '取消',
		        fromLabel : '起始时间',
		        toLabel : '结束时间',
		        customRangeLabel : '自定义',
		        daysOfWeek : [ '日', '一', '二', '三', '四', '五', '六' ],
		        monthNames : [ '一月', '二月', '三月', '四月', '五月', '六月','七月', '八月', '九月', '十月', '十一月', '十二月' ],
		        firstDay : 1
		    }
		});
	

$(".table-responsive #chakan").click(function(){
		var myrel=$(this).attr('rel');
		var myrul='/index.php/Admin/order/detail/order_id/'+myrel;//+myrel;
			layer.open({
			  type: 2,
			  title:'订单信息',
			  shadeClose: true, //点击遮罩关闭
			  skin: 'layui-layer-rim', //加上边框
			  area: ['920px', '620px'], //宽高
			  content: myrul
		})
    });
});

    function get_select_order_id_str() {
        if ($('input[name="alluser_id\[\]"]:checked').length == 0)
            return false;
        var goods_arr = Array();
        $('input[name="alluser_id\[\]"]:checked').each(function () {
            goods_arr.push($(this).val());
        });
        var order_id_str = goods_arr.join(',');
        return order_id_str
    }
	
    //批量操作提交
    function act_submit() {
        //prompt层
        var ids = get_select_order_id_str();
        if (ids == false) {
            layer.alert('请勾选要操作的订单', {icon: 2});
            return;
        }
console.log(ids);
		layer.confirm('确定收款吗？确认收款后会结算给商家。', {
		  btn: ['确定','取消'] //按钮 
		}, function(){
			
		});
    }

	$("#daochu").click(function(){
		var order_sn=$("#order_sn").val();
		var kehu=$("#kehu").val();
		var jiesuan_zt=$("#jiesuan_zt").val();var fenbu_id=$("#fenbu_id").val();var shanghu=$("#shanghu").val();
		var start_time=$("#start_time").val();
		location.href="/Admin/Finance/pda_duizhang?action=daochu&order_sn="+order_sn+"&fenbu_id="+fenbu_id+"&shanghu="+shanghu+"&kehu="+kehu+"&jiesuan_zt="+jiesuan_zt+"&timegap="+start_time;
	})
</script>
</body>
</html>